macos安装homebrew |
您所在的位置:网站首页 › mac 安装homebrew详细教程 › macos安装homebrew |
Homebrew是一款自由及开放源代码的软件包管理系统,用以简化macOS系统上的软件安装过程。对于Appstore中没有的软件,推荐使用此方法安装管理第三方软件。 Homebrew是一款包管理工具,目前支持macOS和linux系统。主要有四个部分组成: brew、homebrew-core 、homebrew-cask、homebrew-bottles。 如果有更换镜像源的想法,强烈推荐使用镜像助手获取执行脚本。 1.执行安装脚本 export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git" export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git" /bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install.sh)" # 2.安装完成后设置 echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles/bottles' >> ~/.zprofile source ~/.zprofile 一、官方安装Homebrew 网址:https://brew.sh/ 中文网址:https://brew.sh/index_zh-cn 命令: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 卸载: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)" 二、国内镜像安装方法 1)获取install文件 获取官网脚本并保存名为 brew_install:raw.githubusercontent.com/Homebrew/install/master/install 2)替换成清华大学的镜像 打开 brew_install 文件,修改如下: 找到如下代码: BREW_REPO = “https://github.com/Homebrew/brew“.freeze CORE_TAP_REPO = “https://github.com/Homebrew/homebrew-core“.freeze 更改为: BREW_REPO = “https://mirrors.ustc.edu.cn/brew.git “.freeze CORE_TAP_REPO = “https://mirrors.ustc.edu.cn/homebrew-core.git“.freeze 注意: 新版本HomeBrew可能没有CORE_TAP_REPO这句代码,如果没有不用新增。 如果这个镜像有问题的话,可以换成其他源(如中科大,下面有写)。 3)执行脚本 打开终端允许脚本 /usr/bin/ruby brew_install 如果此时脚本应该停在 ==> Tapping homebrew/core Cloning into'/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'... 出现这个原因是因为源不通,代码来不下来,解决方法就是更换国内镜像源: 手动执行下面这句命令,更换为中科院的镜像: git clone git://mirrors.ustc.edu.cn/homebrew-core.git/ /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1 然后把homebrew-core的镜像地址也设为中科院的国内镜像 cd "$(brew --repo)" git remote set-url origin https://mirrors.ustc.edu.cn/brew.git cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git 执行更新,成功: brew update 最后用这个命令检查无错误: brew doctor 至此HomeBrew就安装完成了。 三、切换默认源 *** 使用代理:使用代理可以不用切换源 brew支持全局socks代理。使用前加上这一句: export ALL_PROXY=socks5://127.0.0.1:portnumber portnumber 是代理端口号 1)中科大源 替换 Homebrew git -C"$(brew --repo)"remote set-url origin https://mirrors.ustc.edu.cn/brew.git 替换 Homebrew Core git -C"$(brew --repo homebrew/core)"remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git 替换 Homebrew Cask git -C"$(brew --repo homebrew/cask)"remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git brew update 替换 Homebrew-bottles 对于 bash 用户: echo'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles'>> ~/.bash_profile source~/.bash_profile 对于 zsh 用户: echo'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles'>> ~/.zshrc source~/.zshrc 2)清华源 替换 Homebrew git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git 替换 Homebrew Core git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git 替换 Homebrew Cask git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git brew update 替换 Homebrew-bottles 对于 bash 用户: echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile source ~/.bash_profile 3)官方源 替换 Homebrew git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git 替换 Homebrew Core git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git 替换 Homebrew Cask git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask.git brew update 替换 Homebrew-bottles 注释掉bash配置文件里的有关Homebrew Bottles即可恢复官方源。 重启bash或让bash重读配置文件。 或 (未测试) 对于 bash 用户: echo 'export HOMEBREW_BOTTLE_DOMAIN=https://homebrew.bintray.com/bottles/homebrew-bottles' >> ~/.bash_profile source ~/.bash_profile 四、常用命令 搜索软件 brew search 软件名 安装软件 brew install 软件名 卸载软件 brew uninstall 软件名 更新全部软件 brew update 更新指定软件 brew upgrade 软件名 显示已安装软件 brew list brew list 软件名 //查看某软件安装路径 查看哪些软件需要更新 brew outdated 查看帮助 brew help mac下镜像飞速安装Homebrew教程 - 知乎 MacOS 安装 HomeBrew - 简书 镜像助手 - Homebrew macOS(或 Linux)缺失的软件包的管理器 — Homebrew |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |